<template>
    <div class="slideshowSetting">
        <el-card class="box-card">
            <el-button type="primary" @click="addPro">添加</el-button>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column type="index" label="序号" width="180"> </el-table-column>
                <el-table-column prop="name" label="图片" width="180"> </el-table-column>
                <el-table-column prop="address" label="类别"> </el-table-column>
                <el-table-column prop="address" label="跳转链接"> </el-table-column>
                <el-table-column prop="address" label="排序"> </el-table-column>
                <el-table-column prop="address" label="操作">
                    <template slot-scope="scope">
                        <el-button type="primary" @click="editPro(scope.row)">修改</el-button>
                        <el-button type="primary" @click="delePro(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>

        <el-dialog v-if="isEditPro" title="修改Banner信息" :visible.sync="editDialogVisible" width="50%">
            <el-form ref="editform" :model="form" label-width="80px">
                <el-form-item label="类别">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="Banner图">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="跳转链接">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="排序">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="editDialogVisible = false">确 定</el-button>
            </span>
        </el-dialog>

        <el-dialog v-else title="添加Banner信息" :visible.sync="addDialogVisible" width="50%">
            <el-form ref="addform" :model="addform" label-width="80px">
                <el-form-item label="类别">
                    <el-input v-model="addform.name"></el-input>
                </el-form-item>
                <el-form-item label="Banner图">
                    <el-input v-model="addform.name"></el-input>
                </el-form-item>
                <el-form-item label="跳转链接">
                    <el-input v-model="addform.name"></el-input>
                </el-form-item>
                <el-form-item label="排序">
                    <el-input v-model="addform.name"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="addDialogVisible = false">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
  name: 'slideshowSetting',
  data () {
    return {
      tableData: [],
      isEditPro: null,
      editDialogVisible: false,
      editform: {},
      addform: {}
    }
  },
  created () {

  },
  mounted () {

  },
  methods: {
    async editPro (role) {
      this.isEditPro = true
    },

    async delePro (role) {
      const confirmResult = await this.$confirm(
        '此操作将永久删除该商品, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).catch(err => err)

      if (confirmResult !== 'confirm') {
        return this.$message.info('已经取消删除！')
      }
      this.$message.success('删除成功')
    },

    addPro () {
      this.isEditPro = false
    }
  }
}

</script>

<style scoped lang="less">
.el-form {
    display: flex;
    flex-wrap: wrap;
}
.el-form--inline .el-form-item {
    display: flex;
    flex: 50%;
}
.el-form--inline .el-form-item {
    margin-right: 0px;
}
.el-input__inner {
    padding: 0 30px;
}
.el-form-item__content {
    flex: 1;
}
.flex-full {
    flex: 100% !important;
}
.w100 {
    width: 150px;
}
.ml400 {
    margin-left: 600px;
    margin-bottom: 20px;
}
</style>
